This function returns whether a number is positive, negative or neither and returns 1, -1, 0 respectively. For example - sign(458) will return 1, sign(-5) will return -1 and sign(0) will return 0.
sign(n);
参数 | 描述 |
---|---|
.n | 要返回符号的数 |
整数
y += sign(y - mouse_y);
上面的代码将在y上添加1,-1或0,具体取决于结果y - mouse_y>